/*
 * File: exercise7.cpp
 * -------------------
 * This program calculate the average of the integer list.
 * compile command :
 * g++ -Wall -g exercise7.cpp -o exercise7 -lStanfordCPPLib -I ../include/
 */

#include <iostream>
#include "simpio.h"
using namespace std;

const int SENTINEL = -1;

int main()
{
	double average = 0;
	int score = 0;
	int num = 0;
	cout<<"This program calculate the average of the integer list."<<endl;
	cout<<"Enter "<<SENTINEL<<" to signal the end of the list."<<endl;
	while((score = getInteger("? ")) != SENTINEL)
	{
		num++;
		average += score;
	}
	average = average / num;
	cout<<"The average score was "<<average<<endl;
	return 0;
}
